/**
   UserleavewordController
 * Time:2018年6月5日
 */
package com.ssm.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.ssm.entity.Page;
import com.ssm.entity.PageCount;
import com.ssm.entity.Testdanmu;
import com.ssm.entity.Userleaveword;
import com.ssm.entity.vo.PageNumVo;
import com.ssm.entity.vo.SeachByColumn;
import com.ssm.entity.vo.UserleavewordVo;
import com.ssm.entity.vo.VideoMessageVo;
import com.ssm.service.UserleavewordService;

/**
 * @author 15199
 *
 */
@RequestMapping("/Userleaveword")
@Controller
public class UserleavewordController extends BaseController  {
	@Resource
	private UserleavewordService userleavewordService;
	private int pageMax;
	/*弹幕列表*/
	@RequestMapping("/list.do")
	@ResponseBody
	public List<Userleaveword> ulist(@RequestBody PageNumVo pageNumvo){
		Page page=parsePageNo(pageNumvo.getPageNum());
		List<Userleaveword> list=new ArrayList<Userleaveword>();
		list=userleavewordService.getAll(page, new UserleavewordVo());
		return list;
	}
	/*获取最大页数*/
	@RequestMapping("/getPageNum.do")
	@ResponseBody
	public int getPageNum(){
		int n=userleavewordService.getcount();	
		if(n>0){
			PageCount pageCount=new PageCount(n,5);
			return pageCount.getPageMax(); 	
		}
		return 0;
	}
	/*根据传入的参数删除内容*/
	@RequestMapping("/delete.do")
	@ResponseBody
	public String delete(@RequestBody String id) {
		int ulid=parseInt(id);
		int n=userleavewordService.deleteById(ulid);
		if(n>0){
			return "true";
		}else{
			return "false";
		}
	}
	/*批量删除留言信息*/
	@RequestMapping("/batchdelete.do")
	@ResponseBody
	public String batchdelete(@RequestBody List<String> list){
		int n=0;
		for (String str : list) {
			n=userleavewordService.deleteById(parseInt(str));
		}
		if(n>0){
			return "true";
		}
		return "false";
	}








}
